<meta charset="utf-8">
<title>平台快讯</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<meta name="description" content="网站描述">
<meta name="keywords" content="">
<meta name="author" content="wangl">
<link rel="icon" href="http://ow9lg82yy.bkt.clouddn.com/24f5c360-485d-4a6d-9468-2a61c353cf37.ico">
<link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
<link rel="stylesheet" href="//at.alicdn.com/t/font_tnyc012u2rlwstt9.css" media="all">
<link rel="stylesheet" href="/static/css/user.css" media="all">
<link rel="stylesheet" href="/static/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">

</head>
<body class="childrenBody">

<div class="layui-col-xs12">
    <fieldset class="layui-elem-field">
        <legend>快讯</legend>
        <div class="layui-field-box">
            <form class="layui-form" id="searchForm">
                <div class="layui-inline">
                    <a href="addpage" class="layui-btn layui-btn-normal" data-type="addBlogArticle">添加快讯</a>
                </div>
            </form>
        </div>
    </fieldset>
    <div class="layui-form users_list">

        <table cellspacing="0" cellpadding="0" border="0" class="layui-table">
            <thead>
            <tr>
                <th data-field="0" data-unresize="true">
                    <div class="layui-table-cell laytable-cell-1-0 laytable-cell-checkbox"><input
                                type="checkbox" name="layTableCheckbox" lay-skin="primary"
                                lay-filter="layTableAllChoose">
                        <div class="layui-unselect layui-form-checkbox" lay-skin="primary"><i
                                    class="layui-icon"></i></div>
                    </div>
                </th>
                <th data-field="newsid">
                    <div class="layui-table-cell laytable-cell-1-newsid"><span>编号</span></div>
                </th>
                <th data-field="title">
                    <div class="layui-table-cell laytable-cell-1-title"><span>快讯标题</span></div>
                </th>
                <th data-field="content">
                    <div class="layui-table-cell laytable-cell-1-content"><span>快讯内容</span></div>
                </th>
                <th data-field="content">
                    <div class="layui-table-cell laytable-cell-1-content"><span>快讯来源</span></div>
                </th>
                <th data-field="link">
                    <div class="layui-table-cell laytable-cell-1-link"><span>快讯链接</span></div>
                </th>
                <th data-field="publistTime" data-unresize="true">
                    <div class="layui-table-cell laytable-cell-1-publistTime"><span>发布时间</span></div>
                </th>
                <th data-field="9">
                    <div class="layui-table-cell laytable-cell-1-9" align="center"><span>操作</span></div>
                </th>
            </tr>
            </thead>
            <tbody id="newsList">
            </tbody>
        </table>
        <div class="box-tools pull-right">
            <ul class="pagination" id="pagination_ul">
            </ul>
        </div>

    </div>
</div>
</body>
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/layui/layui.js"></script>
<script type="text/javascript" src="/static/js/tools.js"></script>
<script type="text/javascript" src="/static/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="/static/js/CodeConst.js"></script>
<!-- <script type="text/javascript" src="/static/js/jquery-1.10.2.js"></script> -->
<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<script>

    //遍历baseDto
    function loadData(baseDto) {
        if (baseDto.code == ERROR)
            console.log(baseDto.msg);
        else {
            //数据
            var data = baseDto.data.list;
            var text = "";
            $.each(data, function (index, news) {
                if (typeof (news.newsLink) == "undefined") {
                    newsLink = '';
                } else {
                    newsLink = news.newsLink;
                }
                text += "<tr>\n" +
                    "<td><input name=\"ids\" type=\"checkbox\"></td>\n" +
                    "<td>" + news.id + "</td>\n" +
                    "<td>" + news.newsTitle + "</td>\n" +
                    "<td>" + news.newsContent + "</td>\n" +
                    "<td>" + news.newsSource + "</td>\n" +
                    "<td>" + newsLink + "</td>\n" +
                    "<td>" + news.createTime + "</td>\n" +
                    "<td class=\"text-center\" align=\"center\">\n" +
                    "    <a href='/back/content/news/editpage?newsId=" + news.id + "' type=\"button\" class=\"layui-btn layui-btn-xs\">编辑</a>\n" +
                    "    <a href='/back/content/news/del?newsId=" + news.id + "'        type=\"button\" class=\"layui-btn layui-btn-xs\">删除</a>\n" +
                    // "    <a href='/back/content/news/puttop?newsId=" + news.id + "'     type=\"button\" class=\"layui-btn layui-btn-xs\">置顶到首页</a>\n" +
                    "</td>\n" +
                    "</tr>";
            });
            var newsListDom = $("#newsList");
            newsListDom.empty();//清空子元素
            newsListDom.append($(text));
            var pages = baseDto.data.pages;
            var pageNum = baseDto.data.pageNum;

            var pagination_ul = $("#pagination_ul");


        }
    }

    function loadPage(a) {
        var a_jquery = $(a);
        var url = a_jquery.attr("link");
        $.ajax(
            {
                url: url,
                type: "GET",
                success: function (baseDto) {
                    loadData(baseDto);
                }
            }
        );
    }

    layui.use(['laypage', 'layer'], function () {
        var laypage = layui.laypage
            , layer = layui.layer;
        //获取所有广告信息


        // printJson("调用ajax");
        //获取数据
        $.ajax({
            url: "/back/content/news/list",
            type: "GET",
            success: function (baseDto) {
                loadData(baseDto);
                baseDto = baseDto.data;
                laypage.render({
                    elem: 'pagination_ul'
                    , count: baseDto.total
                    , curr: baseDto.fristPage //获取起始页
                    , limit: 10
                    , jump: function (obj) {
                        loadPage(obj.curr);
                    }

                });
            }
        });


        function loadPage(pageNum) {
            $.get("/back/content/news/list?pageNum=" + pageNum, function (baseDto) {
                loadData(baseDto);
            })
        }
    });


</script>


</html>